package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class PrimaryDatetimeField implements ExtractField {

    private int beginIndex;
    private int endIndex;
    private NonSecondPrimaryDatetimeField nonSecondPrimaryDatetimeField;

    public PrimaryDatetimeField(NonSecondPrimaryDatetimeField nonSecondPrimaryDatetimeField) {
        this.beginIndex = nonSecondPrimaryDatetimeField.getBeginIndex();
        this.endIndex = nonSecondPrimaryDatetimeField.getEndIndex();
        this.nonSecondPrimaryDatetimeField = nonSecondPrimaryDatetimeField;
    }

    public PrimaryDatetimeField(int beginIndex, int endIndex) {
        this.beginIndex = beginIndex;
        this.endIndex = endIndex;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public NonSecondPrimaryDatetimeField getNonSecondPrimaryDatetimeField() {
        return nonSecondPrimaryDatetimeField;
    }

    public boolean isYear() {
        if (nonSecondPrimaryDatetimeField == null) {
            return false;
        }
        return nonSecondPrimaryDatetimeField.isYear();
    }

    public boolean isMonth() {
        if (nonSecondPrimaryDatetimeField == null) {
            return false;
        }
        return nonSecondPrimaryDatetimeField.isMonth();
    }

    public boolean isDay() {
        if (nonSecondPrimaryDatetimeField == null) {
            return false;
        }
        return nonSecondPrimaryDatetimeField.isDay();
    }

    public boolean isHour() {
        if (nonSecondPrimaryDatetimeField == null) {
            return false;
        }
        return nonSecondPrimaryDatetimeField.isHour();
    }

    public boolean isMinute() {
        if (nonSecondPrimaryDatetimeField == null) {
            return false;
        }
        return nonSecondPrimaryDatetimeField.isMinute();
    }

    public boolean isSecond() {
        return nonSecondPrimaryDatetimeField == null;
    }

}
